﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using StarsAdmin.Core.DB.Entities;

namespace StarsAdmin.Core.DB.Configs
{
    public class ApiConfig : IEntityTypeConfiguration<ApiEntity>
    {
        public void Configure(EntityTypeBuilder<ApiEntity> builder)
        {
            builder.ToTable("T_Apis");
            builder.Property(p => p.Name).IsRequired().HasMaxLength(64);
            builder.Property(p => p.Label).IsRequired(false).HasMaxLength(64);
            builder.Property(p => p.Path).IsRequired().HasMaxLength(256);
            builder.Property(p => p.HttpMethod).IsRequired(false).HasMaxLength(64);
            builder.Property(p => p.Description).IsRequired(false).HasMaxLength(256);

            // 批量导入添加时简化操作使用，故忽略
            builder.Ignore(p => p.MenuIds);
        }
    }
}